package gamedemo.component.render;

import gamedemo.camera.Camera;
import gamedemo.component.ComponentException;
import gamedemo.geom.Vector3f;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.state.StateBasedGame;


public class BackgroundRenderComponent extends RenderComponent {
	float depth;
	Image image;
	Camera cam;
	
	public BackgroundRenderComponent(Image image, Camera cam,
			float depth) {
		this.cam = cam;
		this.image = image;
		this.depth = depth;
	}
	
	public int getWidth() {
		return image.getWidth();
	}
	
	public int getHeight() {
		return image.getHeight();
	}

	@Override
	public void render(GameContainer gc, StateBasedGame sb, Graphics gr) {
		Vector3f ownerPos = owner.getPosition();
		float scale = cam.getScale().x;
		
		image.draw(ownerPos.x + cam.getPosition().x - cam.getPosition().x / depth, ownerPos.y, owner.getScale());
	}

	@Override
	public void update(GameContainer gc, StateBasedGame sb, int delta) {
		// DO NOTHING
	}

	@Override
	public void init() throws ComponentException {
		// DO NOTHING		
	}
}
